home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / OpenOffice.idb / usr / OpenOffice / help / en / sbasic.jar / text / sbasic / common / 03100700.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-24  |  2.5 KB  |  33 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Const Statement [Runtime]</title><meta name="filename" content="text/sbasic/common/03100700"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         p.P2{
  7.                 }
  8.         span.T1{
  9.                 font-weight:bold;}
  10.         </style></head><body>
  11.   
  12.   
  13.   <help:to-be-embedded Eid="const" xmlns:help="http://openoffice.org/2000/help">
  14.   <p class="Head1"><help:link Id="66600">Const Statement [Runtime]</help:link></p>
  15.   <p class="Paragraph">Defines a string as a constant.</p>
  16.   </help:to-be-embedded>
  17.   <p class="Paragraph"><span class="T1">Syntax</span>:</p>
  18.   <p class="Paragraph">Const Text = Expression <help:key-word value="Const" tag="kw66600_1" xmlns:help="http://openoffice.org/2000/help"/></p>
  19.   <p class="Paragraph"><span class="T1">Parameter</span>:</p>
  20.   <p class="Paragraph">Text: Any constant name which follows the standard variable naming conventions.</p>
  21.   <p class="Paragraph">A constant is a type of variable which helps to improve the readability of a progam. Constants are not defined as a specific type, rather are used merely as program code placeholders. A constant may only be defined in a program once and can never be modified. Use the following statement to define a constant:</p>
  22.   <p class="Paragraph">CONST ConstName=Expression</p>
  23.   <p class="Paragraph">The type of expression is irrelevant. If a program is started, <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic converts the program code internally so that each time a constant is used, <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>the defined expression replaces it. Basically, this is like an internal "Search & Replace" function. Wherever the constant name occurs in the Basic program code, it will be replaced by the expression. For this reason, the type assigned to the constant does not have any relevance since only the internal expression is used.</p>
  24.   <p class="P2">Example:</p>
  25.   <p class="PropText">Sub ExampleConst</p>
  26.   <p class="PropText">Const iVar = 1964</p>
  27.   <p class="PropText">Msgbox iVar</p>
  28.   <p class="PropText">Const sVar = "Program", dVar As Double = 1.00</p>
  29.   <p class="PropText">Msgbox sVar & " " & dVar</p>
  30.   <p class="PropText">end sub</p>
  31.   <p class="PropText"/>
  32.   <p class="PropText"/>
  33.  </body></html>